package com.yq.homework.day25;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author 3307235355@qq.com
 * @since 2022/06/25 16:00
 * 从磁盘上读取一个文本文件（如某个java源代码），
 * 分别统计出文件中英文字母、空格、数字字符的个数。(注意文本文件中的数字指的是数字字符！！！)
 */
public class Demo02 {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader("a.txt"));
        int c = 0;
        int place = 0;
        int number = 0;

        String s;
        while ((s = in.readLine()) != null) {
            char[] chars = s.toCharArray();
            for (int i = 0; i < chars.length; i++) {
                if (chars[i] >= 'a' && chars[i] <= 'z' || chars[i] >= 'A' && chars[i] <= 'Z') {
                    c++;
                }
                if (chars[i] >= '0' && chars[i] <= '9') {
                    number++;
                }
                if (chars[i]==' '){
                    place++;
                }
            }

        }
        System.out.println("c = " + c);
        System.out.println("number = " + number);
        System.out.println("place = " + place);
        in.close();
    }
}
